//
//  WCNParentCareRecordVC.m
//  WCN
//
//  Created by 陈武琦 on 16/3/7.
//  Copyright © 2016年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCNParentCareRecordVC.h"
#import "WCButton.h"
#import "UINavigationItem+Offset.h"
#import "WCNAddCareRecordSheetsPopView.h"
#import "WCNWoundDetailVC.h"
#import "WCNCareSchemeListVC.h"
#import "WCNPatientAddVC.h"
#import "Masonry.h"
#import "WCNRiskAccessmentRecordsVC.h"
#import "WCQestionnaireModel.h"
#import "WCQuestionnaireDetailVC.h"
#import "WCNChoosePageView.h"
#import "WCWeixinTool.h"
#import "JCAlertView.h"
#import "RWDropdownMenu.h"
#import <YTXAnimations/UIView+YTXAnimateCSS.h>


@interface WCNParentCareRecordVC ()
@property (nonatomic) WCNCareRecordVCMode mode;
@property (strong, nonatomic) Patient *patient;
@property (strong, nonatomic) UIControl *maskView;
@property (strong, nonatomic) WCNAddCareRecordSheetsPopView *popView;
@property (strong, nonatomic) UIViewController *currentViewController;
@property (strong, nonatomic) WCNCareRecordVC *nurseRecordsVC;
//问卷
@property (strong, nonatomic)WCNRiskAccessmentRecordsVC *questionnaireVC;
@property(nonatomic, strong)UIView *view1;
@property(nonatomic, strong)UIView *view2;




//伤口纪录的列表
@property (strong, nonatomic) NSArray *wounds;
//点击的伤口纪录
@property (strong, nonatomic) id wound;
//风险评估的种类
@property (strong, nonatomic) NSArray *riskAccessArray;
//风险评估的标题
@property (strong, nonatomic) NSArray *riskAccessTitles;

//风险评估的左侧图标
@property (strong, nonatomic) NSArray *riskAccessIcons;

//选择线
@property (strong, nonatomic) UIView *line;
//选择左边
@property (strong, nonatomic) UIButton *leftBtn;
//选择右边
@property (strong, nonatomic) UIButton *rightBtn;

@property (nonatomic, assign) NSInteger vcType;

@property (nonatomic, assign) NSString *recordId;

@property (weak, nonatomic) MBProgressHUD *hud;

@property (nonatomic,  strong) NSDictionary *woundDict;


@end

@implementation WCNParentCareRecordVC

- (instancetype)initWithTitle:(Patient *)patient mode:(WCNCareRecordVCMode)mode wound:(id)wound {
    self = [super init];
    if (self) {
        _woundDict = wound;
        _patient = patient;
        _mode = mode;
        _wound = wound;
        _nurseRecordsVC = [[WCNCareRecordVC alloc] initWithTitle:patient mode:mode wound:self.wound];
        _nurseRecordsVC.is_comeFromParent = YES;
        defineWeakSelf;
        _nurseRecordsVC.delegateNav = ^(){return weakSelf.navigationController;};
        _questionnaireVC = [[WCNRiskAccessmentRecordsVC alloc] init];
        _questionnaireVC.blockNav = ^(){return  weakSelf.navigationController;};
        _questionnaireVC.recordId = patient.stringId;
        self.recordId = patient.stringId;
       
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = kAppBg;
    self.vcType = 1;
    
    //反回按钮
    WCButton *backButton = [WCButton backButton];
    [backButton addTarget:self action:@selector(pageBack) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationItem addLeftBarButtonItem:backButton];
    
    self.navigationItem.titleView = [self titleView];
    self.titleLabel.text = [self.patient valueForKey:@"name"];

    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 40, kScreenWidth, self.view.frame.size.height - 40)];
    scrollView.backgroundColor = [UIColor blueColor];
    _view1 = _nurseRecordsVC.view;
    _view2 = _questionnaireVC.view;
    [scrollView addSubview:_view1];
    _view1.hidden = NO;
    [scrollView addSubview:_view2];
    _view2.hidden = YES;
    [self.view addSubview:scrollView];
    WCNChoosePageView *pageView = [[WCNChoosePageView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 40) titles:@[@"护理记录",@"风险记录"]];
    [self.view addSubview:pageView];
    defineWeakSelf;
    pageView.choosePageBlock = ^(NSInteger selectIndex){
    
        if (selectIndex == 0) {
            [weakSelf.nurseRecordsVC viewWillAppear:YES];
            weakSelf.view1.hidden = NO;
            weakSelf.view2.hidden = YES;
            weakSelf.vcType = 1;
        }else if (selectIndex == 1){
        
            [weakSelf.questionnaireVC viewWillAppear:YES];
            weakSelf.view1.hidden = YES;
            weakSelf.view2.hidden = NO;
            weakSelf.vcType = 2;
        
        }

    };
   
//    [self.navigationItem addRightBarButtonItem:rightBtn];
    
//    CGRect frame = rightBtn.frame;
//    frame.size.width = 10;
//    frame.size.height = 10;
//    rightBtn.frame  =frame;
    
    
}
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
   
    if (!self.view2.hidden) {
        
        //[self.questionnaireVC viewWillAppear:YES];
    }
    if (!self.view1.hidden) {
        
        [self.nurseRecordsVC viewWillAppear:YES];
    }
    
}


- (void)clickTitleView
{
        WCNPatientAddVC *vc = [[WCNPatientAddVC alloc] initWithPatient:self.patient];
        [self.navigationController pushViewController:vc animated:YES];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
